{:W('Template/top')}
<div class="wrapper clearfix content" style="position: relative;border-top: 1px solid #ddd">
    {:W('Template/left')}
    <div class="rightbox pull-right">
        <div class="ur-here">您当前的位置：<a href="#">代理商管理</a>&gt;合同申请</div>
        <div class="cTitle2">合同申请</div>
        <in name="Think.session.role_id" value="$operatorData">
            <input type="hidden" class="operatorId" value="{$oid}">

            <div class="status">
                <label>运营商：</label>
                <a class="nav-operator-state nav-operator-state0"
                   href="{:U('Agency/contractList', array('id' => I('get.id'), 'oid' => 0))}" style="margin-left:5px;">全部
                </a>
                <foreach name="operatorList" item="vo">
                    <a class="nav-operator-state nav-operator-state{$vo.id}"
                       href="{:U('Agency/contractList', array('id' => I('get.id'), 'oid' => $vo['id']))}">{$vo.display_name}
                    </a>
                </foreach>
            </div>
        </in>

        <div class="main-search">
            <div class="top clearfix">
                <form method="get" action="{:U('Agency/contractList',array('id' => I('get.id'), 'oid' => I('get.oid')))}"
                      class="form-inline">
                    <div class="form-group">
                        <input type="text" class="form-control" name="names" placeholder="请输入代理商姓名" value="{$name}"/>
                    </div>
                    <div class="form-group ml">
                        <label>时间：</label>
                        <input type="text" class="form-control ui-datepicker Wdate" name="start_time"
                               placeholder="开始日期"
                               value="{$startTime}" id="d4322" onclick="WdatePicker({el: $dp.$('d12')})"
                               style="width:80%">
                    </div>
                    <span class="end">到</span>

                    <div class="form-group">
                        <label class="sr-only"></label>
                        <input type="text" class="form-control ui-datepicker Wdate" name="end_time"
                               placeholder="结束日期"
                               value="{$endTime}" id="d4322" onclick="WdatePicker({el: $dp.$('d12')})">
                    </div>
                    <button type="submit" class="btn btn-warning">查询</button>
                </form>
            </div>
            <p></p>

            <form method="post" action="{:U('GetApplyExcel/getAgencyContractExcel',array('id' => I('get.id'), 'oid' => I('get.oid')))}">
                <input type="hidden" name="sname" value="{$name}">
                <input type="hidden" name="start_time" value="{$startTime}">
                <input type="hidden" name="end_time" value="{$endTime}">
                <input type="submit" class="btn btn-success" value="导出生成Excel">
            </form>
        </div>

        <input id="invoiceList" type="hidden" value="{:U('Agency/contractList')}"/>
        <input id="showReject" type="hidden" value="{:U('Agency/showContractReject')}"/>
        <input id="showExpress" type="hidden" value="{:U('Agency/showExpressInfo')}"/>
        <input id="saveExpress" type="hidden" value="{:U('Agency/saveExpressInfo')}"/>
        <input type="hidden" id="showProof" value="{:U('Agency/showProofInfo')}">
        <input type="hidden" id="code" value="{$Think.session.contractCode}">
        <table class="cTable table-hover" width="100%">
            <tr>
                <th width="5%">编号</th>
                <th width="10%">代理商</th>
                <th width="8%">国内合同</th>
                <th width="8%">境外合同</th>
                <th width="8%">单项委托</th>
                <th width="5%">数量</th>
                <th width="5%">单价</th>
                <th width="5%">邮费</th>
                <th width="5%">合计</th>
                <th width="10%">索取方式</th>
                <th width="10%">申请时间</th>
                <th width="10%">审核时间</th>
                <th width="10%">凭证</th>
                <th width="10%">状态</th>
                <th width="12%">操作</th>
            </tr>
            <foreach name="info" item="vo">
                <tr>
                    <td>{$vo.id}</td>
                    <td>{$vo.entity_name}</td>
                    <td class="text-c1">{$vo.inland_count}份</td>
                    <td class="text-c1">{$vo.outbound_count}份</td>
                    <td class="text-c1">{$vo.peritem_count}份</td>
                    <td class="text-c5">{$vo['peritem_count'] + $vo['outbound_count'] + $vo['inland_count']} 份</td>
                    <td class="text-c5">{$vo.contract_fee|getYuan}</td>
                    <td class="text-c5">
                        <if condition="$vo['express_fee'] eq 0">
                            0
                            <else/>
                            {$vo.express_fee|getYuan}
                        </if>
                    </td>
                    <td class="text-c1">
                        <if condition="$vo['request_method'] eq 1">
                            {$vo['peritem_count'] * getYuan($vo['contract_fee']) + $vo['outbound_count'] *
                            getYuan($vo['contract_fee']) + $vo['inland_count'] * getYuan($vo['contract_fee'])}
                            <elseif condition="$vo['request_method'] eq 2 and $vo['express_fee'] eq 0"/>
                            {$vo['peritem_count'] * getYuan($vo['contract_fee']) + $vo['outbound_count'] *
                            getYuan($vo['contract_fee']) + $vo['inland_count'] * getYuan($vo['contract_fee'])}
                            <else/>
                            {$vo['peritem_count'] * getYuan($vo['contract_fee']) + $vo['outbound_count'] *
                            getYuan($vo['contract_fee']) + $vo['inland_count'] * getYuan($vo['contract_fee']) +
                            getYuan($vo['express_fee'])}
                        </if>
                    </td>
                    <td class="method{$vo.id}">
                        <if condition="$vo.request_method eq 1"><span style="color:saddlebrown">自取</span>
                            <elseif condition="$vo.request_method eq 2"/>
                        <span style="color:blue">
                            <if condition="$vo['express_fee'] eq 0">
                                快递 到付
                                <elseif condition="$vo['express_fee'] neq 0"/>
                                快递 包邮
                            </if>
                        </span>
                        </if>
                    </td>
                    <td>{$vo.create_time}</td>
                    <td>{$vo.update_time}</td>
                    <td class="text-c1">{$vo.proof_type} {$vo.proof_code}</td>
                    <td class="text-c5">
                        <if condition="$vo.state eq 1"><span style="color:saddlebrown">待审核</span>
                            <elseif condition="$vo.state eq 2"/>
                            <span class="text-c7">已审核</span>
                            <else/>
                                <span class="text-c8">
                                    <a href="javascript:void(0)" data-toggle="tooltip" data-placement="top"
                                       title="{$vo.memo}" style="color:red">拒绝</a>
                                </span>
                        </if>
                    </td>
                    <td>
                        <if condition="$vo.state eq 1">
                            <div class="btn-group" id="state">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                        aria-expanded="false">
                                    操作<span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu" role="menu">
                                    <li>
                                        <a href="javascript:void(0)"
                                           onclick="passChangeApply({$vo.id}, '{$vo.id|setEncrypt}', {$vo.entity_id|getAgencyState}, {$vo.entity_id|getAgencyAccountState})">已审核</a>
                                    </li>
                                    <li><a href="javascript:void(0)"
                                           onclick="rejectState({$vo.id}, '{$vo.id|setEncrypt}', {:Common\\Top::ApplyStateReject})">拒绝</a>
                                    </li>
                                </ul>
                            </div>

                            <elseif condition="$vo['state'] eq 3"/>
                            <div class="btn-group" id="state">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                        aria-expanded="false">
                                    操作<span class="caret"></span>
                                </button>
                            </div>

                            <elseif condition="($vo['state'] eq 2) AND ($vo['request_method'] eq 2) AND ($vo['express'] neq '')"/>
                            <div class="btn-group" id="state">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                        aria-expanded="false">
                                    操作<span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu" role="menu">
                                    <li>
                                        <a href="javascript:void(0)" onclick="showExpress({$vo.id}, 4)">查看快递信息</a>
                                    </li>
                                    <li>
                                        <a href="javascript:void(0)"
                                           onclick="updateProof({$vo.id}, '{$vo.id|setEncrypt}', {$vo.state}, 4)">更新凭证</a>
                                    </li>
                                </ul>
                            </div>

                            <elseif condition="($vo['state'] eq 2) AND ($vo['request_method'] eq 2) AND (($vo['express'] eq '') OR ($vo['express'] eq NULL))"/>
                            <div class="btn-group" id="state">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                        aria-expanded="false">
                                    操作<span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu" role="menu">
                                    <li>
                                        <a href="javascript:void(0)" onclick="saveExpress({$vo.id}, 4)">填写快递信息</a>
                                    </li>
                                    <li>
                                        <a href="javascript:void(0)"
                                           onclick="updateProof({$vo.id}, '{$vo.id|setEncrypt}', {$vo.state}, 4)">更新凭证</a>
                                    </li>
                                </ul>
                            </div>

                            <else/>
                            <div class="btn-group" id="state">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                        aria-expanded="false">
                                    操作<span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu" role="menu">
                                    <li>
                                        <a href="javascript:void(0)"
                                           onclick="updateProof({$vo.id}, '{$vo.id|setEncrypt}', {$vo.state}, 4)">更新凭证</a>
                                    </li>
                                </ul>
                            </div>
                        </if>
                    </td>
                </tr>
            </foreach>
        </table>
        <notempty name="info">
            <div class="pagebox">
                {$page}
            </div>
        </notempty>
    </div>
</div>

<div class="theme-popover">
    <div class="theme-poptit">
        <a title="关闭" class="closes">&times;</a>

        <div class="modal-header">
            <h4 class="modal-title" id="myModalLabel">拒绝理由</h4>
        </div>
        <div class="modal-body" id="modal_reject">
            <textarea class="form-control" name="reason" style="resize: none;" placeholder="请填写拒绝理由"></textarea>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-warning" id="button">确定</button>
            <button type="button" class="btn btn-default " id="reset">取消</button>
        </div>
    </div>
</div>
<div class="theme-popover-mask"></div>

<div class="modal fade" id="myModalEdit1" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:300px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"
                        data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    填写快递信息
                </h4>
            </div>
            <div class="modal-body">
                联系人：
                <input type="text" class="name" style="border:0px">

                <p>
                    联系电话：
                    <input type="text" class="mobile" style='border:0px'>

                <p>
                    收件人姓名：
                    <input type="text" class="contact_person" style='border:0px;white-space:pre-wrap;'>

                <p>
                    收件人电话：
                    <input type="text" class="contact_phone" style='border:0px;white-space:pre-wrap;'>

                <p>
                    收件人地址：
                    <input type="text" class="contact_addr" style="border:0px;width:70%;white-space:pre-wrap;">

                <p>
                    快递公司：
                    <input type="text" class="form-control express_name" name="exress-name">
                    快递单号：
                    <input type="text" class="form-control express_number" name="express-number">
            </div>
            <div class="modal-footer">
                <div class="pull-right">
                    <button type="button" class="btn btn-primary doSubmit">
                        确定
                    </button>
                    <button type="button" class="btn btn-default cancel"
                            data-dismiss="modal">关闭
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="myModalEdit" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:300px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"
                        data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    填写凭证信息
                </h4>
            </div>
            <div class="modal-body">
                凭证类型：
                <input type="text" class="proof_type form-control" style="border:1px solid #e5e5e5">

                <p>
                    凭证号码：
                    <input type="text" class="proof_code form-control" style='border:1px solid #e5e5e5'>

                <p>
            </div>
            <div class="modal-footer">
                <div class="pull-right">
                    <button type="button" class="btn btn-primary doSubmitTopup">
                        确定
                    </button>
                    <button type="button" class="btn btn-default cancel"
                            data-dismiss="modal">关闭
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
{:W('Template/bottom')}
<script>
    $(function () {
        $("[data-toggle='tooltip']").tooltip();
    });
</script>
</body>
</html>
